package mgorm

import (
	"gitee.com/dreamwood/jxgo/v1/dev"
	"reflect"
)

func getFields(doc Doc) []string {
	tp := reflect.TypeOf(doc)
	if tp.Kind() == reflect.Ptr {
		tp = tp.Elem()
	}
	fields := make([]string, 0)
	for i := 0; i < tp.NumField(); i++ {
		field := tp.Field(i)
		dev.PrintDebug(field.Name)
		fields = append(fields, field.Name)
	}
	return fields
}

func getBsonTag(field reflect.StructField) string {
	tag := field.Tag.Get("bson")
	if tag == "" {
		tag = field.Name
	}
	return tag
}
